layui.use(['element', 'form', 'layedit', 'laydate', 'laypage', 'layer', 'upload'], function() {
    var form = layui.form,
        layer = layui.layer,
        layedit = layui.layedit,
        laydate = layui.laydate,
        upload = layui.upload;
    var laypage = layui.laypage,
        layer = layui.layer;


    form.on('select(trademark)', function(data){
        $("#brand").empty();
        var id = data.value
        $.ajax({
            type:"post",
            url:"selectBrandByTrademarkId",
            data:{'id':id,"tabname":"z_carbrand"},
            dataType: 'json',
            success:function(result){
                if(result.code == 1){
                    layer.msg("获取车系信息失败");
                    return false;
                }
                var cparam = "<option value=''></option>";
                for(var i = 0 ; i < result.data.length ; i++ ){
                    cparam += "<option value='"+result.data[i].id+"'>"+result.data[i].name+"</option>";
                }
                $("#brand").append(cparam)//强制险
                layui.form.render("select");
            }
        })
    })

    form.on('select(trademarkquery)', function(data){
        $("#brandquery").empty();
        var id = data.value;
        $.ajax({
            type:"post",
            url:"selectBrandByTrademarkId",
            data:{'id':id,"tabname":"z_carbrand"},
            dataType: 'json',
            success:function(result){
                if(result.code == 1){
                    layer.msg("获取车系信息失败");
                    return false;
                }
                var cparam = "<option value=''></option>";
                for(var i = 0 ; i < result.data.length ; i++ ){
                    cparam += "<option value='"+result.data[i].id+"'>"+result.data[i].name+"</option>";
                }
                $("#brandquery").append(cparam)//强制险
                layui.form.render("select");
            }
        })
    })
})
